<?php
/**     
  *
  * Copyright (c) 2009, Persistent Systems Limited
  *
  * Redistribution and use, with or without modification, are permitted 
  *  provided that the following  conditions are met:
  *   - Redistributions of source code must retain the above copyright notice, 
  *     this list of conditions and the following disclaimer.
  *   - Neither the name of Persistent Systems Limited nor the names of its contributors 
  *     may be used to endorse or promote products derived from this software 
  *     without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * This Class set the environment amongs bvt,production, int, ppe
  */
class DotNetServicesEnvironment
{
   /**
    * a static variable for BVT environment
    * @static
    */

	public static $BVT_ENVIRONMENT = "bvt";

  /**
    * a static variable for INT environment
    * @static
    */
    public static $INT_ENVIRONMENT = "int";

  /**
    * a static variable for PPE environment
    * @static
    */

    public static $PPE_ENVIRONMENT = "ppe";

  /**
    * a static variable for PROD environment
    * @static
    */
    public static $PROD_ENVIRONMENT = "prod";

    // Default env is set to bvt during development, 
    // will be changed to prod at the time of release 

  /**
    * a static variable for default environment
    * @static
    */
    public static $DEFAULT_ENVIRONMENT = "prod";

  /**
	* a static variable for  environment
	* @static
	*/

    private static $environment = "prod";

  /**
    * a static variable for containing service bus host name in BVT envt,.
    * @static
    */

    private static $BVT_SERVICE_BUS_HOST_NAME = "servicebus.windows-bvt.net";

  /**
    * a static variable for containing ACM host name in BVT envt,.
    * @static
    */
    private static $BVT_ACM_HOST_NAME = "accesscontrol.windows-bvt.net";

  /**
    * a static variable for containing STS host name in BVT envt,.
    * @static
    */

    private static $BVT_STS_HOST_NAME = "accesscontrol.windows-bvt.net";


  /**
    * a static variable for containing service bus host name in INT envt.
    * @static
    */

    private static $INT_SERVICE_BUS_HOST_NAME = "servicebus.int2.windows-int.net";

  /**
    * a static variable for containing ACM host name in INT envt.
    * @static
    */
    private static $INT_ACM_HOST_NAME = "accesscontrol.int2.windows-int.net";

  /**
    * a static variable for containing STS host name in INT envt.
    * @static
    */
    private static $INT_STS_HOST_NAME = "accesscontrol.int2.windows-int.net";

  /**
    * a static variable for containing service bus host name in PPE envt.
    * @static
    */

    private static $PPE_SERVICE_BUS_HOST_NAME = "servicebus.windows-ppe.net";

  /**
    * a static variable for containing ACM host name in PPE envt.
    * @static
    */
    private static $PPE_ACM_HOST_NAME = "accesscontrol.windows-ppe.net";

  /**
    * a static variable for containing STS host name in PPE envt.
    * @static
    */
    private static $PPE_STS_HOST_NAME = "accesscontrol.windows-ppe.net";

  /**
    * a static variable for containing service bus host name in Production envt.
    * @static
    */

    private static $PROD_SERVICE_BUS_HOST_NAME = "servicebus.windows.net";

  /**
    * a static variable for containing ACM host name in Production envt.
    * @static
    */
    private static $PROD_ACM_HOST_NAME = "accesscontrol.windows.net";

  /**
    * a static variable for containing STS host name in Production envt.
    * @static
    */
    private static $PROD_STS_HOST_NAME = "accesscontrol.windows.net";

   /**
	`* This function return the environment which is set e.g bvt,prod,int and ppe
	 * @static
	 * @return string $environment
	 */
	public static function getEnvironment()
    {
       return DotNetServicesEnvironment::$environment;
    }

	/**
	`* This function sets the environment e.g bvt,prod,int and ppe
	 * @static
	 * @param string environment name
	 */
    public static function setEnvironment($environment)
    {
       DotNetServicesEnvironment::$environment = $environment;
    }

    /**
	`* This function return the ACM host name
	 * @static
	 * @return string
	 */
    public static function getACMHostName()
    {
        switch (DotNetServicesEnvironment::$environment)
        {
            case DotNetServicesEnvironment::$BVT_ENVIRONMENT:
                return DotNetServicesEnvironment::$BVT_ACM_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$INT_ENVIRONMENT:
                return DotNetServicesEnvironment::$INT_ACM_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$PPE_ENVIRONMENT:
                return DotNetServicesEnvironment::$PPE_ACM_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$PROD_ENVIRONMENT:
                return DotNetServicesEnvironment::$PROD_ACM_HOST_NAME;
                break;
        }
    }

    /**
	`* This function return the STS hostname
	 * @static
	 * @return string $environment
	 */
    public static function getSTSHostName()
    {
        switch (DotNetServicesEnvironment::$environment)
        {
            case DotNetServicesEnvironment::$BVT_ENVIRONMENT:
                return DotNetServicesEnvironment::$BVT_STS_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$INT_ENVIRONMENT:
                return DotNetServicesEnvironment::$INT_STS_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$PPE_ENVIRONMENT:
                return DotNetServicesEnvironment::$PPE_STS_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$PROD_ENVIRONMENT:
                return DotNetServicesEnvironment::$PROD_STS_HOST_NAME;
                break;
        }
    }

   /**
	`* This function return the service bus hostname
	 * @static
	 * @return string $environment
	 */
    public static function getServiceBusHostName()
    {
        switch (DotNetServicesEnvironment::$environment)
        {
            case DotNetServicesEnvironment::$BVT_ENVIRONMENT:
                return DotNetServicesEnvironment::$BVT_SERVICE_BUS_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$INT_ENVIRONMENT:
                return DotNetServicesEnvironment::$INT_SERVICE_BUS_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$PPE_ENVIRONMENT:
                return DotNetServicesEnvironment::$PPE_SERVICE_BUS_HOST_NAME;
                break;

            case DotNetServicesEnvironment::$PROD_ENVIRONMENT:
                return DotNetServicesEnvironment::$PROD_SERVICE_BUS_HOST_NAME;
                break;
        }
    }

	public static function getMessageBufferUri($protocol ,$serviceNamespaceDomain , $messageBufferName )
	{
		return $protocol."://".$serviceNamespaceDomain.".".
			DotNetServicesEnvironment::getServiceBusHostName()."/".$messageBufferName."/";
	}
}
?>